<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>冒泡排序</title>
    <style>
        * {
            margin: 0;
            padding: 0;
        }

        .box {
            width: 200px;
            height: 200px;
            margin: 50px auto;
            border: 1px red solid;
        }
    </style>
</head>

<body>
    <div class="box" id="box">
        <button id="btn">点击</button>
    </div>
    <script>
        var box = document.getElementById('box')
        var btn = document.getElementById('btn')
        btn.onclick = function (event) {
            event = event || window.event
            console.log('btn')
            if (event.stopPropagation) {
                event.stopPropagation()
            } else {
                event.cancleBubble = true
            }
        }
        box.onclick = function () {
            console.log('box')

        }
    </script>
</body>

</html>